
<template>
   <div class="taking" v-if="!flag">
      <div class="taking-mjx">
         <div class="mai">
            <div class="mai-word">买家秀</div>
            <div class="mai-tak">共{{ getNum(allTalk) }}条评论<van-icon name="arrow" /></div>
         </div>
         <div class="desc">
            <div v-for="(item, index) in desc.slice(0, 4)" :key="index">
               {{ item.tag_name }}</div>
         </div>
         <div class="taking-img">
            <div class="mai-img" v-for="(item, index) in list.slice(0, 4)" :key="index">
               <img :src="`${item.comment_images[0]}`" alt="">
            </div>
         </div>
      </div>
      <div v-if="recommend" class="taking-recommend">
         <div class="recommend-word">为你推荐</div>
         <div class="recommend-item">
            <div class="recommend-box" v-for="(item, index) in recommend" :key="index">
           
               <div><img :src="`${item.image_url}`" alt=""></div>
               <div class="box-name">{{ item.name }}</div>
               <div class="box-price">
                  <i>￥{{ item.price }}</i>
                  <del v-if="item.price !== item.market_price">￥{{ item.market_price }}</del>
               </div>
            </div>
         </div>
      </div>
   </div>
   <div class="nodata" v-if="flag">该商品已下架</div>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import { getInfo } from '../../api/info'
import { useRoute, useRouter } from "vue-router";
const flag  = ref(false)

const route = useRoute();
const router = useRouter();
const uid = ref(route.params.id);
const desc = ref([])
const allTalk = ref();
const list = ref([]);
const recommend = ref([])

const info = async () => {
   let data = await getInfo(uid.value)
   if (data.code==0) {
      allTalk.value = data.data.goods_share_datas.comments.detail.comments_total
      desc.value = data.data.goods_share_datas.comments.detail.comment_tags
      list.value = data.data.goods_share_datas.comments.list;
      recommend.value = data.data.related_recommend.data
   }else{
      flag.value = true
   }


}

const getNum = (num) => {
   if (num > 10000) {
      num = (num / 10000).toFixed(0) + 'w' + '+'
   }
   return num
}

onMounted(() => {
   info()
})

</script>



<style scoped>
.taking-mjx {
   margin: 10px auto;
   width: 94vw;
   height: 160px;
   background-color: #fff;
   border-radius: 10px;
}

.mai {
   padding: 5px 10px;
   padding-top: 5px;
   display: flex;
   justify-content: space-between;
}

.mai-word {
   color: rgb(0, 0, 0);
   font-size: 14px;
   font-weight: 500;
}

.mai-tak {
   color: rgb(0, 0, 0);
   font-size: 11px;
   opacity: 0.5;
}

.desc {
   display: flex;
   color: rgb(0, 0, 0);
   font-size: 12px;
   opacity: 0.9;
}

.desc div {
   background-color: rgba(255, 112, 0, 0.08);
   border-radius: 4.33333px;
   margin-right: 11px;
   margin-top: 8.66667px;
   padding: 3.33333px 8.66667px;
}

.taking-img {
   display: flex;
}

.mai-img {
   margin: 5px 5px;


}

.mai-img img {
   border-radius: 6px;
   width: 82px;
   height: 82px;
}

.taking-recommend {
   margin: 10px auto;
   width: 94vw;
   height: 220px;
   background-color: #fff;
   border-radius: 10px;
}

.recommend-word {
   padding-left: 10px;
   padding-top: 12px;
   color: rgb(0, 0, 0);
   font-size: 14px;
   font-weight: 500;

}

.recommend-item {
   display: flex;
   overflow: scroll;
}

.recommend-item::-webkit-scrollbar {
   height: 0px;
}

.recommend-box {
   margin: 5px 4px;
}

.recommend-box img {
   width: 100px;
}

.box-name {
   color: rgb(0, 0, 0);
   font-size: 12px;
   margin-bottom: 5.33333px;
   margin-top: 11px;
   width: 100px;
}

.box-price i {
   color: rgb(24, 24, 24);
   font-size: 13px;
   font-weight: 500;
}

.box-price del {
   margin-left: 5px;
   color: rgba(0, 0, 0, 0.3);
   font-size: 10px;
   margin-bottom: 1px;
   text-decoration-line: line-through;
}
.nodata{
   text-align:center;
}

</style>